<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <link rel="icon" href="https://cnd.hterobot.com/vue/public/favicon.ico">
  <script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
  <script src="https://cdn.hterobot.com/vue/public/js/build/qrcode.min.js"></script>
  <title>二维码</title>
</head>

<body>

</body>

</html>
<script>
  window.onload = function () {
    /* eslint-disable no-undef */
    //汲取字符串变成数组
    const state = window.location.href.split(',');
    for (var a = 1; a < state.length; a++) {
      const dom = document.createElement("canvas");
      const num = fuz(state[a])
      QRCode.toCanvas(
        dom,
        num, {
          width: 300,
          height: 300,
          colorDark: "#000000",
          colorLight: "#ffffff",
        },
        function (error) {
          if (error) console.error(error);
          console.log("success!");
        }
      )
      $("body").append(dom);
    }

    function fuz(state) {
      const redirect_uri = encodeURIComponent(`https://node.hterobot.com/security/wechat/usepassowrd`);
      return `https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc38a242cea953176&redirect_uri=${redirect_uri}&response_type=code&scope=snsapi_userinfo&state=${state}#wechat_redirect`;
    }
  }
</script>